Java的list筛选重复的数据然后移除掉

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/**
* 筛选出重复数据然后然移除掉;
* @author wjk
* @Date 2021-09-16
*/

private List<AttendEmployeeMonth> getAttendEmployeeMonthRmHaveAttendEmployee(List<AttendEmployeeMonth> attendEmployeeMonthList) {
//根据列表查询这些员工是否已经做过考勤记录
List<AttendEmployeeMonth> attendEmployeeMonthListOld = attendEmployeeMonthService.getEmployeeListByAuditBtyArchiveList(attendEmployeeMonthList);
//若有,则剔除掉该员工,重新组成列表,

List<AttendEmployeeMonth> attendEmployeeMonthNew = new ArrayList<AttendEmployeeMonth>();

for(AttendEmployeeMonth attendEmployeeMonth :attendEmployeeMonthList){
for(AttendEmployeeMonth attendEmployeeMonthOld : attendEmployeeMonthListOld){
if (attendEmployeeMonth.getBtyArchicesId().equals(attendEmployeeMonthOld.getBtyArchicesId())){
attendEmployeeMonthNew.add(attendEmployeeMonth);
}
}
}
attendEmployeeMonthList.removeAll(attendEmployeeMonthNew);
//若没有,直接进行之后的操作
return attendEmployeeMonthList;
}
继开 wechat
欢迎加我的微信,共同交流技术